package card;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class CardGame {
    public static final String[] suits={"♥","♦","♣","♠"};

    public List<Card> buyCard(){
        List<Card> list=new ArrayList<>();
        for (int i = 0; i < 4; i++) {
            for (int j = 1; j <= 13; j++) {
                String suit=suits[i];
                int rank=j;
                Card card=new Card(rank,suit);
                list.add(card);
            }
        }return list;
    }
    public void shuffle(List<Card> cardList){
        Random random=new Random();
        for (int i =cardList.size()-1 ;i >0 ; i--) {
            int dex=random.nextInt(i);
           swap(cardList,i,dex);
        }

    }
public void swap(List<Card> cardList,int i,int dex){
       Card temp=cardList.get(i);
       cardList.set(i,cardList.get(dex));
       cardList.set(dex,temp);
}
}
